package org.vectrics.user.web.struts;

import javax.servlet.jsp.JspException;

import org.vectrics.domain.Domain;
import org.vectrics.hibernate.ThreadProperties;
import org.vectrics.provider.CoreServiceLocator;
import org.vectrics.struts.VectricsStrutsAction;
import org.vectrics.struts.VectricsActionData;
import org.vectrics.user.Person;

public class SaveGlobalUserPrivilegesAction extends VectricsStrutsAction {

	public SaveGlobalUserPrivilegesAction() {
		super();
	}

	
	protected String doExecute(VectricsActionData actionData) throws JspException {
		Person person = CoreServiceLocator.getPersonService().findPersonById(new Long(actionData.getRequest().getParameter("personId")));
		UserPrivilegesHelper userPrivilegeHelper = new UserPrivilegesHelper();
		boolean global = true;
		//userPrivilegeTypeSet allRoleTypes = CoreServiceLocator.getPersonService().findGlobalRoleTypes();
		Domain domain = actionData.getAuthDomain();
		userPrivilegeHelper.saveRoles(actionData, person, domain, true);
		
		GlobalUserPrivilegesForm form = (GlobalUserPrivilegesForm)actionData.getForm();
		actionData.getRequest().setAttribute("personId", new Long(form.getPersonId()));
		return VectricsStrutsAction.FORWARD_SUCCESS;
	}

	
	
}
